package at.irian.jsfatwork.broker.domain.account;

import at.irian.jsfatwork.broker.domain.stock.Stock;

/**
 * @author Thomas Spiegl
 */
class SecuritiesAccountBalance {

    private Stock stock;

    private Integer balance = 0;

    SecuritiesAccountBalance(Stock stock) {
        this.stock = stock;
    }

    void add(Stock stock, Integer quantity) {
        if (this.stock.equals(stock)) {
            balance = balance + quantity;
        }
    }

    public boolean isCovered(Integer quantity) {
        return balance.compareTo(quantity) > 0;
    }

    public Stock getStock() {
        return stock;
    }

    public Integer getBalance() {
        return balance;
    }
}